package com.neusoft.ysu.populationmanagement.controller;


import com.neusoft.ysu.populationmanagement.entity.CommonResult;
import com.neusoft.ysu.populationmanagement.entity.Population;
import com.neusoft.ysu.populationmanagement.service.impl.PopulationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qym
 * @since 2025-06-13
 */
@RestController
@RequestMapping("/population")
@CrossOrigin
public class PopulationController {
    @Autowired
    PopulationServiceImpl populationService;
    @RequestMapping("/insert")
    public CommonResult insertPop(Population population) {
        System.out.println("123123");
        return populationService.insertPop(population);
    }
    @RequestMapping("/update")
    public CommonResult updatePop(Population population) {
        return populationService.updatePop(population);
    }
    @RequestMapping("/delete")
    public CommonResult deletePop( Population population) {
        return populationService.deletePop(population);
    }
    @RequestMapping("/selectByAdress")
    public CommonResult selectByAddress(String area) {
        System.out.println(area);
//        return populationService.selectByAddress(area);
        CommonResult result = populationService.selectByAddress(area);
        return result;
    }
    @RequestMapping("/queryByAdress")
    public CommonResult queryByAddress(String area) {

//        CommonResult result = populationService.selectByAddress(area);
//        System.out.println(result);
//        List<Population> popData=populationService.queryByAddress(area);
        CommonResult res=populationService.queryByAddress(area);
        return res;
    }
}
